﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using ClassLibrary;

namespace ObTookit.Auto
{
    public class ApiCoder : BaseCoder
    {
        public string CreateCode()
        {
            FieldObject pkFO = GetIdObject();
            string text = ReadTemplate(Template);
            text = text.Replace("[#AUTHOR#]", Author);
            text = text.Replace("[#CREATED#]", CreateDate);

            text = text.Replace("[#ApiNS#]",AutoObj.ApiNS);
            text = text.Replace("[#ClsName#]", AutoObj.ClsName);
            text = text.Replace("[#ClsBaseApi#]", AutoObj.ApiBaseCls);

            text = text.Replace("[#sClsName#]", StringUtil.FirstChar(AutoObj.ClsName, "_", false));

            text = text.Replace("[#IdAlias#]", pkFO.Alias);
            text = text.Replace("[#IdSysType#]", GetIdType(pkFO.Type));

            text = text.Replace("[#apiPrefix#]", AutoObj.ApiPrefix);
            
            return text;
        }
    }
}
